﻿using Sustainalytics.Entities;
using System;
using System.Collections.Generic;

namespace Sustainalytics.DataLayer.Tests.Utility
{
    public static class MostRecentActivityTestingData
    {
        public static MostRecentActivity[] MostRecentActivityList { get; set; }

        static MostRecentActivityTestingData()
        {
            MostRecentActivityList = new MostRecentActivity[100];
            CreateMostRecentActivity(0, 100);
        }

        private static void CreateMostRecentActivity(int fromIndex, int toIndexExclusive)
        {
            for (int index = fromIndex; index < toIndexExclusive; index++)
            {
                MostRecentActivity portfolio = new MostRecentActivity
                {
                    Id = Guid.Parse("00000000-0000-0000-0000-" + (index + 1).ToString().PadLeft(12, '0')),
                    CompanyId = Guid.Parse("00000000-0000-0000-0000-" + (index + 1).ToString().PadLeft(12, '0')),
                    CompanyName = string.Format("Company test {0}", index + 1),
                    LastAccessedDate = DateTime.Now.AddDays(-index),
                    CompanyTicker = "Ticker " + index,
                    UserId = Guid.Parse("fa88a9e9-2f83-11e4-83fb-d89d67630ddc"),
                    UniverseIds = new List<int> { 1, 2 }
                };
                MostRecentActivityList[index] = portfolio;
            }
        }

        /// <summary>
        /// Initialize unit test data.
        /// </summary>
        public static void InitializeRepo(IMostRecentActivityRepository repo)
        {
            foreach (MostRecentActivity activity in MostRecentActivityTestingData.MostRecentActivityList)
            {
                repo.AddMostRecentActivity(activity);
            }
        }

        /// <summary>
        /// Cleanup unit test data.
        /// </summary>
        public static void CleanupMostRecentActivityRepo(IMostRecentActivityRepository repo)
        {
            repo.Drop();
        }
    }
}
